//(3)创建actions处理异步修改数据
import axios from "axios";
export default  {
    //actions不能修改数据 !!!只能让commit修改 所以形参接收对象解构出commit

    //1.等2秒累加不传参 只接受一个commit
    waitIncreament({ commit }){
        setTimeout(() => {
            //让commit修改修改数据
            commit("increament")
        }, 1500);
    },


    //2.等2秒累加传参 接收第二个参数是对象
    waitIncreamentN({ commit } , payload){
        setTimeout(() => {
            //让commit修改修改数据并传参
            commit("increamentN" , payload)
        }, 1500);
    },

    //3.发送ajax请求获取数据并修改state
    async getMovieListRequest({commit}){
        const result = await axios.get(
            "https://pcw-api.iqiyi.com/search/recommend/list?channel_id=1&data_type=1&mode=11&page_id=2&ret_num=48&session=b9fd987164f6aa47fad266f57dffaa6a"
        );
        //把数据给commit处理添加到state中
        commit("getMovieList" , result.data.data.list)
    },
}